/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package game;

import java.io.IOException;
import java.util.ArrayList;
import org.lwjgl.LWJGLException;
import sengine.*;

/**
 *
 * @author twoodf5611
 */
public class GameMain {

    private Level eng;
    private PlayerCharacter cha = new PlayerCharacter();
    private PartyCharacter partner = new PartyCharacter(cha);
    private ArrayList<String> partySprites = new ArrayList<>();

    public GameMain() throws IOException {
        partySprites.add("luigi.png");
        partySprites.add("mew.jpg");
        partySprites.add("megaman.png");
        for (String str : partySprites) {
            Texture.loadTexture("left" + str);
            Texture.loadTexture("right" + str);
        }
        eng = new Level();
        cha = new PlayerCharacter(300, 700);
        cha.setTexture(Texture.loadTexture("rightstill.png"));
        eng.addSprite(cha);
        cha.setLevel(eng);
        cha.setPartySprites(partySprites);
        eng.addKeyListener(cha);

        partner = new PartyCharacter(cha);
        partner.setPhysType(Object2D.PhysicsType.FLOATING);
        partner.setTexture(Texture.loadTexture("right" + partySprites.get(0)));
        eng.addSprite(partner);
        partner.setLevel(eng);
        cha.setPartner(partner);

        SimpleGun gun = new SimpleGun();
        cha.equip(gun);
        eng.addSprite(gun);

        createStage();

        // An enemy
        EnemyCharacter enemy = new EnemyCharacter(650, 400);
        eng.addSprite(enemy);
        
        Sprite endpt = new Sprite(4100, 200, 100, 500);
        endpt.setTexture(Texture.loadTexture("win-point.png"));
        endpt.setPhysType(Object2D.PhysicsType.FLOATING);
        eng.addSprite(endpt);
        
        eng._clearRmQueue();
    }

    private void createStage() {
        ArrayList<Sprite> platforms = new ArrayList<>();
        
        // Ground
        platforms.add(new Sprite(0, 700, 100000, 200));
        platforms.add(new Sprite(1000, 500, 250, 50));
        platforms.add(new SpawnPoint(1100, 300, 2500));
        platforms.add(new Sprite(1400, 600, 100, 100));
        platforms.add(new SpawnPoint(1400, 200, 4000));
        platforms.add(new Sprite(1900, 550, 100, 150));
        platforms.add(new SpawnPoint(1900, 200, 4000));
        platforms.add(new Sprite(2300, 500, 100, 200));
        platforms.add(new ContactSpawnPoint(2300, 200, 2000));
        platforms.add(new Sprite(3000, 500, 100, 200));
        platforms.add(new ContactSpawnPoint(3000, 200, 2000));
        platforms.add(new ContactSpawnPoint(3500, 400, 4000));
        
        for (Sprite sprite : platforms) {
            sprite.setPhysType(Object2D.PhysicsType.FIXED);
            sprite.setTexture(Texture.loadTexture("platform.png"));
            eng.addSprite(sprite);
        }

    }

    public static void main(String[] args) throws LWJGLException, IOException {
        GameMain game = new GameMain();
        game.eng.run();

    }
}
